<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #id2 {
            width: 100px;
            height: 100px;
            background: blue;
            display: table-cell;
            vertical-align: middle;
            text-align: center;
        }
        #id3 {
            background: red;
            display: inline-block;
            width: 50%;
            height: 50%;
        }
    </style>
</head>
<body>
    <div id="id1">
        <div id="id2">
            <div id="id3">
                测试一下
            </div>
        </div>
    </div>
    <script>
        // ID 可以直接使用
        console.log(id2.offsetWidth);
    </script>
</body>
</html>